var xmlHttp;
var page=0;
var local="http://47.104.10.151";


var order_bid_id1;
var order_bid_id2;
var order_bid_id3;
var order_bid_id4;
var order_bid_id5;
var order_bid_id6;


function creatxmlHTTP() {
    if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlHttp=new XMLHttpRequest();
    }else {
        // IE6, IE5 浏览器执行代码
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    return xmlHttp;
}
function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}
function getInvite() {
    var kid=getCookie('userId');
    var url = local+":8080/login/displayCompany_Code";
    xmlHttp = creatxmlHTTPInvite();
    var txt = "";//用于存储拼接字符串；
    //获取数据
    //拼接字符
    txt = "user_Id=" + kid;
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    function creatxmlHTTPInvite() {
        if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlHttp=new XMLHttpRequest();
        }else {
            // IE6, IE5 浏览器执行代码
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        return xmlHttp;
    }
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            document.getElementById("invite_code").value=json.msg;
        }
    }
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}

function getInvite() {
    var kid=getCookie('userId');
    var url = local+":8080/login/displayCompany_Code";
    xmlHttp = creatxmlHTTPInvite();
    var txt = "";//用于存储拼接字符串；
    //获取数据
    //拼接字符
    txt = "user_Id=" + kid;
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    function creatxmlHTTPInvite() {
        if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlHttp=new XMLHttpRequest();
        }else {
            // IE6, IE5 浏览器执行代码
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        return xmlHttp;
    }
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            var result=xmlHttp.responseText;
            var json=eval("("+result+")");
            document.getElementById("invite_code").value=json.msg;
        }
    }
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}
function onClickAjax_getBid() {
    xmlHttp = creatxmlHTTP();
    //获取主页的用户
    var keyId=getCookie('userId');
    var txt = "";//用于存储拼接字符串；
    var url=local+":8080/voteBid/findVoteBidByStatus2";
    //拼接字符
    txt = "voteuser_id=" + keyId + "&page=" + page;
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);


    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            var result = xmlHttp.responseText;
            var json = eval("(" + result + ")");

            totalPages=json.data.totalPages;

            var input1 = document.getElementsByName("Bid1");
            if (json.data.content[0].tax_status == 0) {
                input1[8].value = "无税率";
            } else if(json.data.content[0].tax_status == 1){
                input1[8].value = "17%";
            }
            order_bid_id1=json.data.content[0].keyId;
            input1[0].value = json.data.content[0].company_code;
            input1[1].value = json.data.content[0].voteBid_code;
            input1[2].value = 1;
            input1[3].value = json.data.content[0].product_name;
            input1[4].value = json.data.content[0].model;
            input1[5].value = json.data.content[0].size;
            input1[6].value = json.data.content[0].brand;
            input1[7].value = json.data.content[0].inventory;
            input1[9].value = json.data.content[0].area;
            input1[10].value = json.data.content[0].bid_status;

            var input2 = document.getElementsByName("Bid2");

            if (json.data.content[1].tax_status == 0) {
                input2[8].value = "无税率";
            } else if(json.data.content[1].tax_status == 1){
                input2[8].value = "17%";
            }
            order_bid_id2=json.data.content[1].keyId;
            input2[0].value = json.data.content[1].company_code;
            input2[1].value = json.data.content[1].voteBid_code;
            input2[2].value = 2;
            input2[3].value = json.data.content[1].product_name;
            input2[4].value = json.data.content[1].model;
            input2[5].value = json.data.content[1].size;
            input2[6].value = json.data.content[1].brand;
            input2[7].value = json.data.content[1].inventory;
            input2[9].value = json.data.content[1].area;
            input2[10].value = json.data.content[1].bid_status;

            var input3 = document.getElementsByName("Bid3");
            if (json.data.content[2].tax_status == 0) {
                input3[8].value = "无税率";
            } else if(json.data.content[2].tax_status == 1){
                input3[8].value = "17%";
            }
            order_bid_id3=json.data.content[2].keyId;
            input3[0].value = json.data.content[2].company_code;
            input3[1].value = json.data.content[2].voteBid_code;
            input3[2].value = 3;
            input3[3].value = json.data.content[2].product_name;
            input3[4].value = json.data.content[2].model;
            input3[5].value = json.data.content[2].size;
            input3[6].value = json.data.content[2].brand;
            input3[7].value = json.data.content[2].inventory;
            input3[9].value = json.data.content[2].area;
            input3[10].value = json.data.content[2].bid_status;

            var input4 = document.getElementsByName("Bid4");
            if (json.data.content[3].tax_status == 0) {
                input4[8].value = "无税率";
            } else if(json.data.content[3].tax_status == 1){
                input4[8].value = "17%";
            }
            order_bid_id4=json.data.content[3].keyId;
            input4[0].value = json.data.content[3].company_code;
            input4[1].value = json.data.content[3].voteBid_code;
            input4[2].value = 4;
            input4[3].value = json.data.content[3].product_name;
            input4[4].value = json.data.content[3].model;
            input4[5].value = json.data.content[3].size;
            input4[6].value = json.data.content[3].brand;
            input4[7].value = json.data.content[3].inventory;
            input4[9].value = json.data.content[3].area;
            input4[10].value = json.data.content[3].bid_status;

            var input5 = document.getElementsByName("Bid5");
            if (json.data.content[4].tax_status == 0) {
                input5[8].value = "无税率";
            } else if(json.data.content[4].tax_status == 1){
                input5[8].value = "17%";
            }
            order_bid_id5=json.data.content[4].keyId;
            input5[0].value = json.data.content[4].company_code;
            input5[1].value = json.data.content[4].voteBid_code;
            input5[2].value = 5;
            input5[3].value = json.data.content[4].product_name;
            input5[4].value = json.data.content[4].model;
            input5[5].value = json.data.content[4].size;
            input5[6].value = json.data.content[4].brand;
            input5[7].value = json.data.content[4].inventory;
            input5[9].value = json.data.content[4].area;
            input5[10].value = json.data.content[4].bid_status;

            var input6 = document.getElementsByName("Bid6");
            if (json.data.content[5].tax_status == 0) {
                input6[8].value = "无税率";
            } else {if(json.data.content[5].tax_status == 1)
                input6[8].value = "17%";
            }
            order_bid_id6=json.data.content[5].keyId;
            input6[0].value = json.data.content[5].company_code;
            input6[1].value = json.data.content[5].voteBid_code;
            input6[2].value = 6;
            input6[3].value = json.data.content[5].product_name;
            input6[4].value = json.data.content[5].model;
            input6[5].value = json.data.content[5].size;
            input6[6].value = json.data.content[5].brand;
            input6[7].value = json.data.content[5].inventory;
            input6[9].value = json.data.content[5].area;
            input6[10].value = json.data.content[5].bid_status;


        }
    }

}




function creatxmlHTTP111() {
    if(window.XMLHttpRequest){
//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlHttp=new XMLHttpRequest();
    }else {
        // IE6, IE5 浏览器执行代码
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    return xmlHttp;
}

function confmFH1_bid() {
    xmlHttp = creatxmlHTTP111();
    txt ="order_id="+order_bid_id1;
    var url = local+":8080/voteBid/orderChangeTo2";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    //传输结束
}

function confmFH2_bid() {
    xmlHttp = creatxmlHTTP111();
    txt ="order_id="+order_bid_id2;
    var url = local+":8080/voteBid/orderChangeTo2";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    //传输结束
}
function confmFH3_bid() {
    xmlHttp = creatxmlHTTP111();
    txt ="order_id="+order_bid_id3;
    var url = local+":8080/voteBid/orderChangeTo2";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    //传输结束
}
function confmFH4_bid() {
    xmlHttp = creatxmlHTTP111();
    txt ="order_id="+order_bid_id4;
    var url = local+":8080/voteBid/orderChangeTo2";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    //传输结束
}
function confmFH5_bid() {
    xmlHttp = creatxmlHTTP111();
    txt ="order_id="+order_bid_id5;
    var url = local+":8080/voteBid/orderChangeTo2";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    //传输结束
}
function confmFH6_bid() {
    xmlHttp = creatxmlHTTP111();
    txt ="order_id="+order_bid_id6;
    var url = local+":8080/voteBid/orderChangeTo2";//服务器URL
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    //传输结束
}


































function nextPage_bid() {
    page++;
    if(totalPages>page){
        onClickAjax_getBid();
    }
    else alert("已经是最后一页");
}


function beforePage_bid() {
    page--;
    if(page>=0){
        onClickAjax_getBid();
    }
    else alert("第一页");
}